#ifndef __LOG_INFO_H__
#define	__LOG_INFO_H__

#include <stdio.h>
#include <string.h>
#include "usart.h"

#if(USART1_DMA_MODE)
	#define LOG_HANDLE  (huart2)
#else
	#define LOG_HANDLE  (huart1)
#endif


#define LOG_BUFF_LEN 128

#define LOG_LEVEL_NONE          (0)
#define LOG_LEVEL_EXCPT         (1)
#define LOG_LEVEL_ERR           (2)
#define LOG_LEVEL_WARN          (3)
#define LOG_LEVEL_INFO          (4)
#define LOG_LEVEL_DEBUG         (5)
#define LOG_LEVEL_APPEND        (6)
#define LOG_LEVEL_VERBOSE       (7)

extern char DebugLogBuff[LOG_BUFF_LEN];
extern unsigned char Syslog_Level;

#define G_LOG(_LVL_, _LVL_TEXT_, fmt, _FORMAT_...)                                              \
    do                                                                                          \
    {                                                                                           \
        if (LOG_LEVEL_##_LVL_ <= Syslog_Level)                                                  \
        {                                                                                       \
            snprintf(DebugLogBuff, LOG_BUFF_LEN, "%s"fmt, _LVL_TEXT_, ##_FORMAT_);          \
            printf("%s\r\n",DebugLogBuff);    \
        }                                                                                       \
    } while (0)

#define LogV(...)   G_LOG(VERBOSE, "[V] ", __VA_ARGS__)
#define LogA(...)   G_LOG(APPEND,  "[A] ", __VA_ARGS__)
#define LogD(...)   G_LOG(DEBUG,   "[D] ", __VA_ARGS__)
#define LogI(...)   G_LOG(INFO,    "[I] ", __VA_ARGS__)
#define LogW(...)   G_LOG(WARN,    "[W] ", __VA_ARGS__)
#define LogE(...)   G_LOG(ERR,     "[E] ", __VA_ARGS__)

typedef enum {
	OscConfig_Error = 0,
	ClockConfig_Error,
	CRCConfig_Error,
	TaskCreate_Error,
	QueueCreate_Error,
	EventGroupCreate_Error,
	HardwareCheck_Error,
	HardwareReset_Error,
	CRC_Init_Error,
	SemaphoreCreate_Error,
	TimerCreate_Error,
	TimerStart_Error,
	MutexCreate_Error,
}Info_Type;

void Log_Info(Info_Type info);

#endif
